<template>
	<div>
		<BannerAndNotice></BannerAndNotice>
		<!-- <div>首页</div> -->
		<!-- 直播区 -->
		<live :liveCourses="liveCourses" :liveTotal="liveTotal"></live>
		<!-- 视频区 -->
		<videoShow style="margin-top: 20px;" :videos="videos" :videoTotal="videoTotal"></videoShow>
		<!-- 回到顶部 -->
		<BackTop></BackTop>
	</div>
</template>

<script>
	import BannerAndNotice from './BannerAndNotice.vue'
	import axios from 'axios';
	import Live from "./components/Live/Live.vue"
	import VideoShow from "./components/Video/Video.vue"
	import BackTop from "./components/BackTop/BackTop.vue"
	export default {
		name: 'Index',
		data() {
			return {
				liveCourses: [],
				videos: [],
				liveTotal: 0,
				videoTotal: 0,
				loading: true,
				dataText: "  "
			}
		},
		components: {
			Live,
			VideoShow,
			BackTop,
			BannerAndNotice
		},
		methods: {
			// 首页展示数据-->无查询展示
			selectLiveByLimit() {
				axios.get(this.$global_msg.liveRoute + '/liveCourse/selectByLimit', {

					})
					.then((res) => {
						// console.log(res)
						this.liveCourses = res.data.data
						this.liveTotal = res.data.count
						this.changeLoadingType();
					}).catch((response) => {
						console.log(response);
						this.changeLoadingType();
					})
			},
			selectVideoByLimit() {
				axios.get(this.$global_msg.videoRoute + '/video/selectByLimit', {

					})
					.then((res) => {
						// console.log(res)
						this.videos = res.data.data
						this.videoTotal = res.data.count
						this.changeLoadingType();
					}).catch((response) => {
						console.log(response);
						this.changeLoadingType();
					})
			},
			changeLoadingType() {
				this.dataText = "暂无数据"
				this.loading = false
			},
		},
		mounted() {
			// 查询直播区数据
			this.selectLiveByLimit()
			// 查询视频区数据
			this.selectVideoByLimit()
			// 每当进入无条件搜索页面时，将session中存储的值变为空字符串
			sessionStorage.setItem("cName", "")
		}
	};
</script>

<style>
	div {
		color: black;
	}
</style>
